define(function (require,exports,module){
	/**--tmpl-require--**/
	//require("JTemplate");
	var template = require("template");


	require('jdialog');
	common = require('common');



	exports.init = function(){
		/**--tmpl-todo--**/

		/**-- deleteopt --**/
		$(".js-delete").click(function(){
			var id = $(this).attr('data-id');
			layer.confirm('确定要删除吗',['确定','取消'],function(){
				layer.load();
				$.post(exports.deleteUrl,{id:id},function(data){
					layer.closeAll('loading');
					if(data.code == 0 || data.code=='success'){
						layer.msg('删除成功');
						document.location.reload();
					}else{
						layer.msg(data.message);
					}
				},'json');
			});
		});
		


		//合同 查看弹窗
		$(".contract").on("click","[data-act='look']",function(){
			var id = $(this).attr("data-id");
			var pay_way = $(this).data("pay_way");

			common.ajaxHandle({
				url:"/admin/contract/details",
				data:{id:id},
				callback:function(item){
					data = item.data;
					data["pay_way"]=pay_way;
					var temp = template("lookTemp",data);
					layer.open({
						type:1,
						title:"合同详情",
						area:"600px",
						content:temp

					})
				}
			});

		});
		//合同 查看弹窗
		$(".contract").on("click","[data-act='print']",function(){
			var id = $(this).attr("data-id");
			var pay_way = $(this).data("pay_way");

			common.ajaxHandle({
				url:"/admin/contract/detailsAndProduct",
				data:{id:id},
				callback:function(item){
					data = item.data;
					data["pay_way"]=pay_way;
					var temp = template("printTemp",data);
					layer.open({
						type:1,
						title:"合同详情",
						area:"1200px",
						content:temp

					})
				}
			});

		});
		/**--tmpl-othertodo--**/
	};

	/**--tmpl-otherfunction--**/
});

function printtable(printpage){


	var headstr='<head><link rel="stylesheet" type="text/css" href="/res/mpe/scss/css/member/order-min.css?v=9423da5359" /> ' +
		'</head>';
	var footstr="<body></body>";

	var newstr=$("#"+printpage).prop("outerHTML");

	var printPage = $("<div id='printPage' style='font-size:14px;left:0px;top:0px;z-index:9999;background:#fff;width:100%;height;100%;position:absolute;'></div>");
	printPage.append($(headstr + newstr + footstr));
	$(document.body).after(printPage);
	$(document.body).css('display','none');

	window.print();

	$('#printPage').remove();
	$(document.body).css('display','block');

	return false;
}